<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>吉车惠后台管理系统</title>
	<%@include file="/global/global-other.jsp" %>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
	</style>
	<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=E1ec2431e3702cc907807aca57390206"></script>
	<title>地图展示</title>
</head>
<style type="text/css">
	body{
		margin:0;
		height:100%;
		width:100%;
		position:absolute;
		font-size:12px;
	}
	#allmap{
		position: absolute;
		top:0;
		left: 0;
		right:0;
		bottom:0;
	}


	#tip input[type="text"]{
		height:25px;
		border:1px solid #ccc;
		padding-left:5px;
		border-radius:3px;
		outline:none;
	}
	#pos{
		height: 70px;
		background-color: #fff;
		padding-left: 10px;
		padding-right: 10px;
		position:absolute;
		font-size: 12px;
		right: 10px;
		bottom: 30px;
		border-radius: 3px;
		line-height: 30px;
		border:1px solid #ccc;
	}
	#pos input{
		border:1px solid #ddd;
		height:23px;
		border-radius:3px;
		outline:none;
	}

	#result1{
		max-height:300px;
	}
</style>
<script type="text/javascript">

</script>
<body>
<div id="allmap"></div>
<div id="tip">
	<%--<b>请输入关键字：</b>--%>
	<%--<input type="text" id="keyword" name="keyword" value="" onkeydown='keydown(event)' style="width: 95%;"/>--%>
	<%--<div id="result1" name="result1"></div>--%>
</div>
<div id="pos">
	<b>鼠标左键在地图上单击获取坐标</b>
	<br><div>经度：<input type="text" id="lngX" name="lngX" value="" disabled="disabled"/>&nbsp;纬度：<input type="text" id="latY" name="latY" value="" disabled="disabled"/></div>
	<input id="lng" name="lng" type="hidden" value="${lng}">
	<input id="lat" name="lat" type="hidden" value="${lat}">
	<input id="address" name="address" type="hidden" value="">
</div>
</body>
</html>
<script type="text/javascript">
	$(function(){
		parent.parent.$.messager.progress('close');
	});
	$(function() {
		submitForm = function($dialog,$map){
			var lngX = $("#lngX").val();
			var latY = $("#latY").val();
			var address = $("#address").val();
			$map.setjwd(lngX,latY,address);
			$dialog.close();
		};
	})

	// 百度地图API功能
	var lng_value=$("#lng").val();
	var lat_value=$("#lat").val();
	if(lng_value==""||lat_value==""||lng_value==0||lat_value==0) {
		lat_value=43.843611; //纬度
		lng_value=126.556055;//经度
	}
	var map = new BMap.Map("allmap");    // 创建Map实例
	map.centerAndZoom(new BMap.Point(lng_value,lat_value), 13);  // 初始化地图,设置中心点坐标和地图级别
	map.addControl(new BMap.MapTypeControl());   //添加地图类型控件
	map.setCurrentCity("吉林");          // 设置地图显示的城市 此项是必须设置的
	map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
	point = new BMap.Point(lng_value,lat_value);
	var marker = new BMap.Marker(point);
	map.addOverlay(marker);
	$("#lngX").val(lng_value);
	$("#latY").val(lat_value);
	map.addEventListener("click", function (e) {
		map.clearOverlays();
		$("#lngX").val(e.point.lng);
		$("#latY").val(e.point.lat);
		point = new BMap.Point(e.point.lng, e.point.lat);
		var marker = new BMap.Marker(point);
		map.addOverlay(marker);

		var url = 'https://api.map.baidu.com/geocoder/v2/?ak=E1ec2431e3702cc907807aca57390206&callback=?&location=' + e.point.lat + ',' + e.point.lng + '&output=json&pois=1';
		$.getJSON(url, function (res) {
			$("#address").val(res.result.formatted_address);
		});

	});
</script>
